﻿Imports Negocio
Imports Excepciones

Public Class LabelExt
    Inherits Label
    Implements IControlTranslatable

    Sub New()
        Me.BackColor = Color.Transparent
    End Sub

    Public Sub Translate(ctrls As List(Of Control)) Implements IControlTranslatable.Translate
        Try
            Dim ctrl As Control = ctrls.Find(AddressOf FindByControlName)
            Me.Text = ctrl.Caption
        Catch ex As Exception
            Throw New ControlNotSupportedLocalizationException()
        End Try
        Throw New ControlFoundLocalizationException()
    End Sub

    Private Function FindByControlName(ctrl As Control) As Boolean
        If ctrl.Nombre = Me.Name Then
            Return True
        Else
            Return False
        End If
    End Function

End Class
